How is it done?

A and B want to generate a secret key

The Public Givens are:

A large prime number n

g = primitive mod of n

A chooses a random large number x and sends it to B X= gx mod n

B chooses a random large number y and sends it to AY = gy mod n

A computes k= Yx mod n

B computes k’= Xy mod n

The secret key k= k’= gxy mod n

The value k cannot be computed by anyone listening since only n, g,

X, Y values are known, and it is difficult to compute the log to obtain

x and y.

For example:

g= 6 = 3 5 mod n

n = 29

A chooses x = 101

X = 6101

B chooses y = 5 3

Y = 65 3

A computes k = 65 3 * 101

B computes k’ = 6101* 5 3